<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$id=intval($_RQ['workerid']);
	if(!$id){
		exi('请选择医生','error','jy_zhongyi/index/');
	}
	$this->session('id',$id);
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'id'=>$id);
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	$item=pdo_get('jy_zhongyi_worker',$params);
	$label=str_array($item['label']);
	$item['label']=array();
	foreach($label as $lv){
		$item['label'][]=pdo_get('jy_zhongyi_label',array('id'=>$lv,'uniacid'=>$_SESSION['uniacid']));
	}
	$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
	$item['lessontitle']=pdo_getcolumn('jy_zhongyi_lesson',array('id'=>$item['lesson_id']),'title');
	$item['storetitle']=pdo_getcolumn('jy_zhongyi_store',array('id'=>$item['storeid']),'title');
	$months=$this->model('lesson')->get_months($item['id'],$item['storeid']);
	$return['months']=$months;
	$return['item']=$item;
	$return['post']=array('weekid'=>0,'lessonid'=>$_RQ['lessonid'],'storeid'=>$lesson['storeid']);
	set_html('title',$item['name']);
	exi($return);
}
if($_RQ['op']=='get_lesson'){
	$params=array('weekid'=>intval($_RQ['weekid']),'uniacid'=>$_SESSION['uniacid'],'status'=>1);
	//排序门店
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;	
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$return['status']=0;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'fields'=>$fields,
		'orderby'=>$orderby,
	);
	$list=pdo_getslice('jy_zhongyi_lesson_pai',$params,array($pindex,$psize),$total,$fields,'','id desc');
	$sum=0;
	if($list){
		$sum=count($list);
		foreach($list as &$item){
			$item['worker']=pdo_get('jy_zhongyi_worker',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['workerid']));
			$item['store']=pdo_get('jy_zhongyi_store',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['storeid']));
			$item['area_title']=pdo_getcolumn('jy_zhongyi_area',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['area_id']),'title');
			if($item['ontime']<time()){
				$item['statustitle']='已上课';
			}else{
				$item['statustitle']='未上课';
			}
			$item['ontime']=$this->model('lesson')->get_uptime($item['ontime']);
		}
	}
	$return['list']=$list;
	$return['success']=1;
	exi($return);
}